using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DAO;
using DTO;

namespace BUS
{
    public static class GiaoVienBUS
    {
        #region Huỳnh Tấn Công
        public static bool ThemGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            
            DataRow dr;
            DataTable dt;
            dt = GiaoVienDAO.DanhSachGiaoVien();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if (dr["MaGV"].ToString().Equals(GiaoVienDTO.MaGV))
                    return false;
            }
            return GiaoVienDAO.ThemGiaoVien(GiaoVienDTO);

        }

        public static bool TimGiaoVienTheoMa(GiaoVienDTO GiaoVienDTO)
        {
          
            DataRow dr;
            DataTable dt;
            dt = GiaoVienDAO.DanhSachGiaoVien();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if (dr["MaGV"].ToString().Equals(GiaoVienDTO.MaGV))
                    return true;
            }
            return false;
        }

        public static bool TimGiaoVienTheoTen(GiaoVienDTO GiaoVienDTO)
        {
           
            DataRow dr;
            DataTable dt;
            dt = GiaoVienDAO.DanhSachGiaoVien();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if (dr["TenGV"].ToString().Equals(GiaoVienDTO.TenGV))
                    return true;
            }
            return false;
        }
        public static bool CapNhatGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            DataRow dr;
            DataTable dt;
            dt = GiaoVienDAO.DanhSachGiaoVien();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
               
                if (dr["MaGV"].ToString().Equals(GiaoVienDTO.MaGV))
                    return GiaoVienDAO.CapNhatGiaoVien(GiaoVienDTO);
            }
            return false;
        }
         public static bool XoaGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            DataRow dr;
            DataTable dt;
            dt = GiaoVienDAO.DanhSachGiaoVien();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                if (dr["MaGV"].ToString().Equals(GiaoVienDTO.MaGV))
                    return GiaoVienDAO.XoaGiaoVien(GiaoVienDTO);
            }
            return false;
        }
         public static DataTable DanhSachGiaoVien()
        {
            return GiaoVienDAO.DanhSachGiaoVien();
        }
        public static DataTable DanhSachMonHoc()
        {
            return GiaoVienDAO.DanhSachMonHoc();
        }
        #endregion

        #region Nguyen Thanh Duy

        public static DataTable GetTableGV()
        {
            return GiaoVienDAO.GetTableGV();
        }

        #endregion
    }
}

